package com.redrose.flutterdemo.ui.fragments;
import android.os.Bundle;
import android.support.annotation.Nullable;
import com.redrose.flutterdemo.R;
import com.redrose.flutterdemo.databinding.FragmentHomeLayoutBinding;
import com.redrose.flutterdemo.flutter.FlutterHandler;

import io.flutter.facade.Flutter;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.view.FlutterView;

/**
 * Desc:
 *
 * @author: RedRose
 * Date: 2019/5/19 0019
 * Email: yinsxi@163.com
 */
public class HomeFragment extends BaseFragment<FragmentHomeLayoutBinding>{
    @Override
    public int setLayout() {
        return R.layout.fragment_home_layout;
    }

    @Override
    public void initData() {
        // initialRoute 初始化路由名称
        FlutterView view = Flutter.createView(getActivity(),getLifecycle(),"home");
        mBinding.container.addView(view);
        MethodChannel methodChannel = new MethodChannel(view,"com.redrose.methodChannel");
        EventChannel eventChannel = new EventChannel(view,"com.redrose.eventChannel");
        FlutterHandler mHandler = new FlutterHandler(this);
        methodChannel.setMethodCallHandler(mHandler);
        eventChannel.setStreamHandler(mHandler);
    }

    @Override
    public void initEvent() {

    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initState();
    }

    /**
     * 动态的设置状态栏  实现沉浸式状态栏
     *
     */
    private void initState() {
    }

}
